home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-25 | 13.1 KB | 482 lines | [TEXT/MMCC] |
- Modifications to MacApp 3.1 for CodeWarrior
- 1.0d3 6/25/94 Please see @@@, below, for an important typo.
- Also please note that the fixes for 6-13-94 MPTP compiler only
- affect that compiler. Earlier and later versions don't have
- the problem.
- 6/22/94
- ••••••••••••••••••••••••••••••
- in UMenuMgr.cp replace the *h to *pHNullMenuProc in: (search for BlockMove until
- you find the commented out version and replace it with the 2nd version)
- //••JS•• said original is a bug in System 7.5
- // BlockMove(&aMDEFUPP, *h, sizeof(RoutineDescriptor));
- BlockMove(&aMDEFUPP, *pHNullMenuProc, sizeof(RoutineDescriptor));
-
- ••••••••••••••••••••••••••••••
- In UMenuMgr.cp change original to:
- //----------------------------------------------------------------------------------------
- // EndMenuSetup:
- //----------------------------------------------------------------------------------------
- void EndMenuSetup(MenuHandle aMenuHandle,
- Boolean isHierarchical,
- void* staticLink)
-
- {
- long newFlags;
-
- if (IsSetupMenu(aMenuHandle, isHierarchical))
- {
- newFlags = (*aMenuHandle)->enableFlags;
- // If any items are enabled, enable the menu
- if (newFlags != 0)
- {
- newFlags = (1 | newFlags);
- (*aMenuHandle)->enableFlags = newFlags;
- }
-
- // If the menu's enabled state changed, we have to draw the menu bar.
- if (((newFlags & 1) == 1) != ((SetupStructPtr)staticLink)->wasEnabled[(*aMenuHandle)->menuID])
- InvalidateMenuBar();
-
- // Restore the menuproc.
- (*aMenuHandle)->menuProc = ((SetupStructPtr)staticLink)->savedProcs[(*aMenuHandle)->menuID];
-
- // menuWidth set to 0 by routines that require CalcMenuSize, by
- // calling NeedCalcMenu.
- //See workaround below
- //if (!(*aMenuHandle)->menuWidth)
- // CalcMenuSize(aMenuHandle);
- }
- //•••JS Bug workaround•••
- // menuWidth set to 0 by routines that require CalcMenuSize, by
- // calling NeedCalcMenu.
- if (!(*aMenuHandle)->menuWidth)
- CalcMenuSize(aMenuHandle);
- } // EndMenuSetup
-
-
- ••••••••••••••••••••••••••••••
-
- in PascalString.h change original to:
- friend inline Boolean operator==(const CString& s1,
- const char* s2);
- friend inline Boolean operator==(const char* s1,
- const CString& s2);
- friend inline Boolean operator==(const CString& s1,
- const CString& s2);
-
- friend inline Boolean operator!=(const CString& s1,
- const char* s2);
- friend inline Boolean operator!=(const char* s1,
- const CString& s2);
- friend inline Boolean operator!=(const CString& s1,
- const CString& s2);
-
- friend inline Boolean operator>(const CString& s1,
- const char* s2);
- friend inline Boolean operator>(const char* s1,
- const CString& s2);
- friend inline Boolean operator>(const CString& s1,
- const CString& s2);
-
- friend inline Boolean operator<(const CString& s1,
- const char* s2);
- friend inline Boolean operator<(const char* s1,
- const CString& s2);
- friend inline Boolean operator<(const CString& s1,
- const CString& s2);
-
- friend inline Boolean operator>=(const CString& s1,
- const char* s2);
- friend inline Boolean operator>=(const char* s1,
- const CString& s2);
- friend inline Boolean operator>=(const CString& s1,
- const CString& s2);
-
- friend inline Boolean operator<=(const CString& s1,
- const char* s2);
- friend inline Boolean operator<=(const char* s1,
- const CString& s2);
- friend inline Boolean operator<=(const CString& s1,
- const CString& s2);
-
- Be careful to only replace the "friends" listed here. There should be 18. This change is
- necessary to be compatable with CW3.5
- ••••••••••••••••••••••••••••••
-
- IMPORTANT This change is only necessary for the 6-13-94 build of the compiler. Only
- MW beta testers have this version (MPTP members); later MPTP versions have fixed the bug.
- All other users can ignore it.
-
- In PascalString.h change original to: (I've included a line or 2 above and below the
- necessary change)
-
- // Used to create a toolbox type Str255 from our CString. This is simply a type
- // coercion! Both CString and Str255 are expected to be pascal-style strings.
-
- //needed for CW Bug; defined in MacAppHeaders940613.cp
- #ifdef _940613CWBug
- inline operator unsigned char*();
- /*
- //The following needs to be put in PascalString.cp; N.B. inline isn't used
- CString::operator unsigned char*()
- {
- return (unsigned char *) this;
- } // for non-const CString
- */
- #else
- inline operator unsigned char*()
- {
- return (unsigned char *) this;
- } // for non-const CString
- #endif
- operator const unsigned char*() const; // for const CString
-
- //------------------------------------------------------------------------------------
- ••••••••••••••••••••••••••••••
- IMPORTANT This change is only necessary for the 6-13-94 build of the compiler. Only
- MW beta testers have this version (MPTP members); later MPTP versions have fixed the bug.
- All other users can ignore it.
-
- @@@ In PascalString.cp put the following anywhere (such as just after the #includes):
-
- //added for a CW Bug in the 6-13-94 MPTP compiler
- //it only affects code in PascalString.cp and .h
-
- #ifdef _940613CWBug
- CString::operator unsigned char*()
- {
- return (unsigned char *) this;
- } // for non-const CString
- #endif
-
-
- ••••••••••••••••••••••••••••••
-
-
- In UObject.h change original to
- //----------------------------------------------------------------------------------------
- // TObject: Definition of the system's root object
- //----------------------------------------------------------------------------------------
-
- DeclareClassDesc(TObject);
-
- // ••• JS NEW ••• singleobject + forceclassidfirst + classdescmany
-
- #if qMultipleInheritance || qPowerPC || defined(__MWERKS__) || defined(THINK_C) || defined(__SC__)
- #if (qDebug || qSym) && defined(__MWERKS__)
- // make sure CodeWarrior puts fClassID first, not the vtable
- struct ForceClassIDFirst
- {
- ClassID fClassID;
- };
- class TObject : public ForceClassIDFirst
- #else
- // assume the other compilers already put fClassID first (for Jasik)
- class TObject
- #endif
- #else
- // for MPW C only and no MI, descend from SingleObject, so vtables are smaller
- class TObject : public SingleObject
- #endif
- {
- DeclareClass(TObject);
-
- public:
-
- #if (qDebug || qSym) && !defined(__MWERKS__)
- ClassID fClassID; // Used to do object validation in debug mode.
- #endif
-
- //------------------------------------------------------------------------------------
- // Initializer and I<Method>.
- //------------------------------------------------------------------------------------
-
- ••••••••••••••••••••••••••••••
- In UDebug.h change original to
- class CStackFrame
- {
- private: // data fields
- ptrdiff_t fFramePtr;
-
- public: // methods
- CStackFrame(void* framePtr);
- CStackFrame(long framePtr = 1);
- //CK
- #if !__MWERKS__
- CStackFrame(ptrdiff_t framePtr);
- //CK
- #endif
-
- ••••••••••••••••••••••••••••••
- In UDebug.cp change original to
- //CK
- #if !__MWERKS__
- //----------------------------------------------------------------------------------------
- // CStackFrame::CStackFrame:
- //----------------------------------------------------------------------------------------
- CStackFrame::CStackFrame(ptrdiff_t framePtr)
- {
- fFramePtr = framePtr;
- } // CStackFrame::CStackFrame
- //CK
- #endif
- •••
- //CK
- #if !qPowerPC && !__MWERKS__
- //was #if !qPowerPC
-
- case 'segu':
- gUnloadAllSegs = !gUnloadAllSegs;
- break;
-
- #endif
- •••
- //CK
- #if !qPowerPC && !__MWERKS__
- //was #if !qPowerPC
-
- ((TCheckBox *) this->FindSubView('segu'))->SetState(gUnloadAllSegs, false);
- #endif
- •••
- void ShowSegments()
- {
- //CK
- #if !qPowerPC && !__MWERKS__
- //was #if !qPowerPC
-
-
- ••••••••••••••••••••••••••••••
- Put the following in UFailure.cp just above the function Assertion()
-
- //CW currently can't output to stderr. What follows is a kludge that puts the message
- //in a window of the Scriptable Text Editor through AppleScript.
- //You must 'manually' open a window in Scriptable Text Editor for this code to work.
- #if __MWERKS__ && qDebug
-
- #include <AppleEvents.h>
- #include <AERegistry.h>
- #include <AEObjects.h>
- #include <AEPackObject.h>
- #include <stdarg.h>
-
-
- pascal OSErr SetText( AEDesc *txtDesc, char * theText) //put the string into the appleEvent
- {
- OSErr myErr;
-
- myErr = AECreateDesc(typeChar,(Ptr)&theText[1], theText[0], txtDesc);
-
-
- return(myErr);
-
- } /*MakeWindowObj*/
- pascal OSErr MakeWindowNumberObj( AEDesc *dMyDoc) //make the outermost container
- {
- AEDesc dNull;
- AEDesc dDoc;
- OSErr myErr;
- long keyData = 1;
- DescType myKeyForm = formAbsolutePosition;
-
- myErr = AECreateDesc(typeLongInteger,(Ptr)&keyData, sizeof(keyData), &dDoc);
-
- if (myErr==noErr)
- myErr = AECreateDesc(typeNull, nil , 0, &dNull); //signals that this is outermost
-
- if (myErr==noErr)
- myErr = CreateObjSpecifier(cWindow /*a window*/, &dNull, myKeyForm, &dDoc, true, dMyDoc);
-
- return(myErr);
-
- } /*MakeWindowNumberObj*/
- pascal OSErr MakeParaNumberObj( AEDesc *dMyDoc, long i) //make the innermost container
- {
- AEDesc dDoc;
- OSErr myErr;
- long keyData = i;
- DescType myKeyForm = formAbsolutePosition;
- AEDesc wind;
-
- MakeWindowNumberObj( &wind);//make the outermost container
-
- myErr = AECreateDesc(typeLongInteger,(Ptr)&keyData, sizeof(keyData), &dDoc);
-
-
- if (myErr==noErr)
- myErr = CreateObjSpecifier('cpar'/*a paragraph*/, &wind, myKeyForm, &dDoc, true, dMyDoc);
-
- return(myErr);
-
- } /*MakeParaNumberObj*/
-
- static Boolean sendMessageToStderr (OSType appid, OSType eventclass, OSType eventid, char * tmp) {
-
- AEAddressDesc adr = {typeNull, nil};
- AppleEvent writeIt = {typeNull, nil};
- AppleEvent selectIt = {typeNull, nil};
- AppleEvent reply1 = {typeNull, nil};
- AppleEvent reply2 = {typeNull, nil};
- OSErr ec;
- AEDesc dMyDoc;
- AEDesc txtDesc;
- //AEDesc slctDesc;
- static long paragraphNum = 1;
- /*1. create the Apple Event, address it to the Scriptable Text Editor app*/
- ec = AECreateDesc (typeApplSignature, (Ptr) &appid, sizeof (appid), &adr);
-
- if (ec != noErr)
- goto error;
-
- ec = AECreateAppleEvent (
- eventclass, eventid, &adr,
-
- 0, 0,
-
- &writeIt);
-
- if (ec != noErr)
- goto error;
- ec = AECreateAppleEvent (
- 'misc', 'slct', &adr,
-
- 0, 0,
-
- &selectIt);
-
- if (ec != noErr)
- goto error;
-
- //create the object container
- ec = MakeParaNumberObj( &dMyDoc, paragraphNum++ );
-
- //make the container a part of the events
- if (AEPutParamDesc (&writeIt, keyDirectObject, &dMyDoc) != noErr)
- goto error;
- if (AEPutParamDesc (&selectIt, keyDirectObject, &dMyDoc) != noErr)
- goto error;
-
-
-
- ec = SetText( &txtDesc, tmp);
-
- if (AEPutParamDesc (&writeIt, keyAEData, &txtDesc) != noErr)
- goto error;
-
- /*2. send the message, don't wait for a reply*/ {
-
- //send the string
- ec = AESend (
- &writeIt, &reply1, kAENoReply ,
-
- kAENormalPriority, kNoTimeOut, nil, nil);
-
- if (ec != noErr)
- goto error;
-
- //selcet the string so that it autoscrolls
- ec = AESend (
- &selectIt, &reply2, kAENoReply ,
-
- kAENormalPriority, kNoTimeOut, nil, nil);
-
- if (ec != noErr)
- goto error;
- }
-
- AEDisposeDesc (&writeIt);
-
- AEDisposeDesc (&selectIt);
-
- AEDisposeDesc (&reply1);
-
- AEDisposeDesc (&reply2);
-
- AEDisposeDesc (&dMyDoc);
-
- AEDisposeDesc (&txtDesc);
-
- return (true);
-
- error:
-
- /*report the error code using ProgramBreak*/ {
-
- Str255 s;
-
- NumToString (ec, s);
-
- ProgramBreak (s);
- }
-
- AEDisposeDesc (&writeIt);
-
- AEDisposeDesc (&selectIt);
-
- AEDisposeDesc (&reply1);
-
- AEDisposeDesc (&reply2);
-
- AEDisposeDesc (&dMyDoc);
-
- AEDisposeDesc (&txtDesc);
-
- return (false);
- } /*sendMessageToStderr*/
-
- int CWfprintf(FILE * /*ignore*/, const char * format, ...)
- {
-
- va_list ap = NULL;
- int result;
- char tmp[512]; //temp storage for output string
- static char str[512]; //we will concatenate strings until we find a return character
- char fail[] = "\pvsprintf failed\n";
- short i;
- static long len = 0; //length of string we are concatenating
-
- Boolean haveApplescript = true; //set to false if you want to output to Jasik's debugger
-
- va_start(ap, format );
- result = vsprintf(tmp, format, ap );
- va_end(ap);
- if ( result >= 0 ) //we were able to convert the fprintf "string" into a C string
- {
- strcat( &str[1], tmp );
- len = strlen(&str[1]); //use [1] because our AppleEvent will be using a Str255
- if (len > 254 ) //see previous comment
- {
- str[0] = 255;
- str[255] = 0x0D;
- }
- else
- {
- str[0] = len;
- if ( str[len] == 0x0A ) // vprintf converts the \n to a linefeed;
- str[len] = 0x0D; //we need to change it back to a \n
- else
- return (result); //don't send the AE yet, we haven't received the \n
-
- }
- }
- else
- strcpy(str, fail); //something went wrong
-
-
- if (haveApplescript)
- sendMessageToStderr ('quil' /*Scritable Text Editor*/, 'core' /*Core suite*/,
- 'setd'/*Set Data*/, str);
- else
- ProgramBreak(&str[1]); //send to Jasik's debugger
- for (i = 0; i <4; i++ ) //initialize string
- str[i] = 0; //more than enough zeros to set the length to zero
- len = 0; //initialize length
- return (result);
-
- }
- #endif //__MWERKS__
- //----------------------------------------------------------------------------------------
- // Assertion:
- //----------------------------------------------------------------------------------------
- •••••••••••••••••••••••
-
-